var vm_renkouhechalist = new Vue({
    el: "#renkouhechalist",
    data: {
        deptid: $("#deptid").val(),		// deptid
        qushiquerenlist: [],// 趋势确认列表custom
        piciid: $("#piciid").val(),//去世确认批次id
        qushiqueren: {},//去世确认
        zhanghuxinxi:{},//专家信息
        zhanghaoxinxiList:[],

        //查询用字段
        danweimingcheng: "",
        danweicengji: "",
        zhuanjiaxingming: "",
        gongzuodanwei: "",
        shifoubiandong: "",
        shifouchuli: "",
        chuliriqi: "",

        pageindex: 1,		// 查询分页初始化页
        pagesize: 10,		// 查询分页初始化页面大小
        pageCount: 0,		// 总页数
        recordCount: 0,	// 总记录数
        targetpage: '', 	// 目标页

        qushiquerens: [],//导入用

        jieshouren:{
            names:'',
            ids:''
        }//站内信接收人

    },
    created: function () {
        var _this = this;
        _this.bindQushiquerenDeptList();

    },
    watch: {
        //监控分页情况，刷新列表
        pageindex: function () {
            this.bindQushiquerenDeptList();
        },

        pagesize: function () {
            this.bindQushiquerenDeptList();
        },
    },
    methods: {

        bindQushiquerenDeptList: function () {
            var _this = this;

            $.post('/system/renkouhecha/renkouhechalist', {
                piciid: _this.piciid,
                danweimingcheng: _this.danweimingcheng,
                danweicengji: _this.danweicengji,
                zhuanjiaxingming: _this.zhuanjiaxingming,
                gongzuodanwei: _this.gongzuodanwei,
                shifoubiandong: _this.shifoubiandong,
                shifouchuli: _this.shifouchuli,
                chuliriqi: _this.chuliriqi,
                pageindex: _this.pageindex,
                pagesize: _this.pagesize,
            }, function (ppData) {
                if (ppData.result == "1") {
                    var data = ppData.resultContent;
                    _this.qushiquerenlist = data.list;

                    var pageInfo = data.PageInfo;
                    _this.pageindex = pageInfo.pageIndex;
                    _this.pageCount = pageInfo.pageCount;
                    _this.recordCount = pageInfo.recordCount;
                    _this.targetpage = '';

                }
            }, "json");
        },
        toZhanneixin:function(qushiquerenitem){
            this.bindJieshouren(qushiquerenitem.jigoudaima)
            var str = "疑似去世专家为：" + qushiquerenitem.xingming +"，请在确认该专家情况"
            $("#biaoti").val("请确认专家去世情况")
            $("#neirong").val(str)
            $("#xiaoxiModalLabel").html("发送站内信")
            $("#xiaoxiModal").modal()
        },
        bindJieshouren:function(deptid){
            var _this = this;

            $.post('/system/xiaoxi/findjieshourenbydeptid', {
                deptid : deptid,
            },function(ppData) {
                if (ppData != null) {
                    if (ppData.result==1){
                        _this.jieshouren  =ppData.resultContent;
                        $("#jieshourennames").val(_this.jieshouren.names);
                        $("#jieshourenids").val(_this.jieshouren.ids);
                    }else{
                        layer.alert(ppData.message);
                    }
                }
            },"json");
        },
        submitHandler:function (s) {
            var prefix = ctx + "system/xiaoxi"
            $("#form-xiaoxi-add").validate({
                focusCleanup: true
            });
            if ($.validate.form("form-xiaoxi-add")) {
                var formdata = $('#form-xiaoxi-add').serialize()
                formdata += "&zhuangtai=" + s;
                $.operate.save(prefix + "/add", formdata,(res)=>{
                    if (res.code == "0") {
                        if(s==1) {
                            layer.open({
                                time: 1000,
                                btn: [],
                                content: "发送邮件成功!",
                            });
                        }else if(s==0){
                            layer.open({
                                time: 1000,
                                btn: [],
                                content: "保存草稿成功!",
                            });
                        }
                        $.form.reset("form-xiaoxi-add");
                        $("#xiaoxiModal").modal("hide")
                    }
                });
            }
        },
        getDate_chuliriqi: function () {
            var _this = this;

            _this.chuliriqi = $("#chuliriqi").val();
        },
        //首页
        firstPage: function () {
            this.pageindex = 1;
        },
        //尾页
        lastPage: function () {
            this.pageindex = this.pageCount;
        },
        //上一页
        prePage: function () {
            var prePage = ((this.pageindex - 1) <= 0) ? 1 : (this.pageindex - 1);
            this.pageindex = prePage;
        },
        //下一页
        nextPage: function () {
            var nextPage = ((this.pageindex + 1) >= this.pageCount) ? this.pageCount : (this.pageindex + 1);
            this.pageindex = nextPage;
        },
        //跳到目标页
        targetPage: function () {
            if (this.targetpage != '' && this.targetpage <= this.pageCount && this.targetpage > 0) {
                this.pageindex = this.targetpage;
                this.targetpage = '';
            }
        },

        reset: function () {
            var _this = this
            _this.danweimingcheng = "",
            _this.danweicengji = "",
            _this.zhuanjiaxingming = "",
            _this.gongzuodanwei = "",
            _this.shifoubiandong = "",
            _this.shifouchuli = "",
            _this.chuliriqi = "",
            _this.bindQushiquerenDeptList()
        },
        toLianxifangshi:function (zhuanjiaitem) {
            var _this = this;
            _this.zhanghuxinxi = zhuanjiaitem

            $.post('/system/deptxinxi/findLianxifangshi', {
                deptid: zhuanjiaitem.jigoudaima,
                rdm: Math.random()
            }, function (ppData) {
                if (ppData != null) {
                    var data = ppData.resultContent;
                    _this.zhanghaoxinxiList = data;
                }
            }, "json");

            $("#myModalLabel2").html("专家及相关层级经办人联系方式");
            $("#lianxifangshiModal").modal();
        },

    },
})